layui.config({
    base: hostUrl + '/static/layuiadmin/'
}).extend({
    index: 'lib/index', //主入口模块
    eleTree: 'car_authority_management/eleTree'
}).use(['index','jquery','eleTree'], function(){
    var $ = layui.jquery;
    var eleTree = layui.eleTree;
    var data1=[
        {
            "label": "车源查询",
            "spread": true,
            "children": [
                {
                    "label": "用户注册",
                    "spread": true,
                    "disabled": true
                },
                {
                    "label": "用户分析",
                    "children": [
                        {
                            "label": "aaaa1",
                            "checked": true
                        }
                    ]
                },
                {
                    "label": "整体分析"
                },
                {
                    "label": "事件分析"
                }
            ]
        },
        {
            "label": "采购管理",
            "children": [
                {
                    "label": "aa1",
                    "disabled": true
                },
                {
                    "label": "bb1",
                    "checked": true
                }
            ]
        },
        {
            "label": "库存管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        },
        {
            "label": "线索管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        },
        {
            "label": "零售订单管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        },
        {
            "label": "门店管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        },
        {
            "label": "App基础管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        },
        {
            "label": "权限管理",
            "children": [
                {
                    "label": "aa1"
                },
                {
                    "label": "bb1"
                }
            ]
        }
    ];
    eleTree.render({
        elem: '.ele1',
        // url: "../../data/home/tree.json",
        // type: "post",
        data: data1,
        showCheckbox: true,
        contextmenuList: ["copy","add","edit","remove"],
        drag: true,
        accordion: true
    });
    //分配权限相关事件,根据需求选择使用
    eleTree.on("add(data1)",function(data) {
        console.log(data);
        // 若后台修改，则重新获取后台数据，然后重载
        // eleTree.reload(".ele1", {where: {data: JSON.stringify(data.data)}})
    })
    eleTree.on("edit(data1)",function(data) {
        console.log(data);
    })
    eleTree.on("remove(data1)",function(data) {
        console.log(data);
    })
    eleTree.on("toggleSlide(data1)",function(data) {
        console.log(data);
    })
    eleTree.on("checkbox(data1)",function(data) {
        console.log(data);
    })
    eleTree.on("drag(data1)",function(data) {
        console.log(data);
    })
    //点击获取选中数据
    $(".layui-btn").on("click",function() {
        console.log(eleTree.checkedData(".ele1"));
    })

});